<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加农资厂商信息</title>
<%@ include file="/WEB-INF/sys/include/css.jsp"%>
<link href="${path}/res/js/webuploader/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form" action="${path}/manufacturer/update.json" method="post">
<div class="form">
	<div class="group">
		<div class="label">*农资厂商名称:</div>
		<div class="item"><input type="text" name="manufacturerName" id="manufacturerName" value="${manufacturer.manufacturerName }"/></div>
	</div>
	<c:if test="${empty manufacturer.groupid }">
	<div class="group">
		<div class="label">所属分组:</div>
		<div class="item">
			<input type="text" id="groupDisplay" name="groupDisplay" />
			<input type="hidden" name="groupname" id="groupname" />
			<input type="hidden" name="groupid" id="groupid" value="${manufacturer.groupid }"/>
		</div>
		<div class="item" id="groupDisplayTip"></div>
	</div>
	</c:if>
	<div class="group">
		<div class="label">*营业执照:</div>
		<div class="item"><input type="text" name="businessNo" id="businessNo" value="${manufacturer.businessNo }"/></div>
	</div>
	<div class="group">
		<div class="label">法人代表:</div>
		<div class="item">
			<div class="item"><input type="text" name="corporatePerson" id="corporatePerson" value="${manufacturer.corporatePerson }"/></div>
		</div>
	</div>
	<div class="group">
		<div class="label">联系人:</div>
		<div class="item">
			<div class="item"><input type="text" name="contactPerson" id="contactPerson" value="${manufacturer.contactPerson }"/></div>
		</div>
	</div>
	<div class="group">
		<div class="label">电话:</div>
		<div class="item"><input type="text" name="phone" id="phone" value="${manufacturer.phone }"/></div>
	</div>
	<div class="group">
		<div class="label">地址:</div>
		<div class="item"><input type="text" name="address"  id="address" value="${manufacturer.address }"/></div>
	</div>
	<div class="group">
		<div class="label">农资厂商级别:</div>
		<div class="item">
		 <select id="manufacturerLevel" name="manufacturerLevel">
		  <option value="0" <c:if test="${manufacturer.manufacturerLevel == 0}">selected="selected"</c:if>>省级</option>
		  <option value="1" <c:if test="${manufacturer.manufacturerLevel == 1}">selected="selected"</c:if>>市级</option>
		  <option value="2" <c:if test="${manufacturer.manufacturerLevel == 2}">selected="selected"</c:if>>地级</option>
	    </select>
	 </div>
	 </div>
	<div class="group">
		<div class="label">地理坐标:</div>
		<div class="item">
			<input type="text" name="manufacturerCoords" id="manufacturerCoords" readonly="readonly" class="select_list" />
			<input type="hidden" id="lng" name="lng" value="${manufacturer.lng }" />
			<input type="hidden" id="lat" name="lat" value="${manufacturer.lat }" />
		</div>
	</div>
	<div class="group">
		<div class="label">邮编:</div>
		<div class="item"><input type="text" name="postcodes"  id="postcodes" value="${manufacturer.postcodes }"/></div>
	</div>
	<div class="group">
		<div class="label">主导产品:</div>
		<div class="item">
			<select id="productDesc" name="productDesc">
			<c:if test="${manufacturer.productDesc == 0}">selected="selected"</c:if>
			<option value="0" <c:if test="${manufacturer.productDesc == 0}">selected="selected"</c:if>>省级</option>
			<option value="1" <c:if test="${manufacturer.productDesc == 1}">selected="selected"</c:if>>市级</option>
			<option value="2" <c:if test="${manufacturer.productDesc == 2}">selected="selected"</c:if>>地级</option>
		</select>
		</div>
	</div>
	<div class="group">
		<div class="label">生产规模:</div>
		<div class="item">
			<select id="productivity" name="productivity">
			<option value="0" <c:if test="${manufacturer.productivity == 0}">selected="selected"</c:if>>0-50</option>
			<option value="1" <c:if test="${manufacturer.productivity == 1}">selected="selected"</c:if>>50-200</option>
			<option value="2" <c:if test="${manufacturer.productivity == 2}">selected="selected"</c:if>>200-500</option>
			<option value="3" <c:if test="${manufacturer.productivity == 3}">selected="selected"</c:if>>500以上</option>
		</select>
		</div>
	</div>
	<div class="group">
		<div class="label">产品认证:</div><!-- 有问题 -->
		<div class="item">
		<select id="ccc" name="ccc">
		<option value="0" <c:if test="${manufacturer.ccc == 0}">selected="selected"</c:if>>无公害农产品</option>
		<option value="1" <c:if test="${manufacturer.ccc == 1}">selected="selected"</c:if>>绿色食品</option>
		<option value="2" <c:if test="${manufacturer.ccc == 2}">selected="selected"</c:if>>有机食品</option>
	</select>
	</div>
	</div>
	<div class="group">
		<div class="label">农资厂商图片:</div>
		<div class="item"><div id="imgurl" class="myuploader myuploader-single">${manufacturer.imgurl }</div></div>
	</div>
	<div class="group">
		<div class="label">备注:</div>
		<div class="item"><textarea id="remark" name="remark">${manufacturer.remark }</textarea></div>
	</div>
	<div class="buttons">
		<button class="highlight" id="submit1" type="button">确定</button>
		<button type="button" id="cancel1">取消</button>
		<c:if test="${not empty manufacturer.groupid }">
		<input type="hidden" id="groupid" name="groupid" value="${manufacturer.groupid}" />
		<input type="hidden" id="manufacturerid" name="manufacturerid" value="${manufacturer.manufacturerid}" />
		</c:if>
		<c:if test="${empty manufacturer.groupid }">
		<input type="hidden" id="manufacturerid" name="manufacturerid" value="${manufacturer.manufacturerid}" />
		</c:if>
	</div>
</div>
</form>
<%@ include file="/WEB-INF/sys/include/script.jsp" %>
<script src="${path}/res/js/webuploader/webuploader.min.js" type="text/javascript"></script>
<script src="${path}/res/js/webuploader/myUploader.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
	if($("#groupDisplay").length){
		createSelect("groupDisplay", "groupid", {
			treeLeafOnly:false,
			tree:{url:'${path}/group/groupJstreeNz.json',
				isAsync:true,
				isLeaf: function(node){return (node.isParent!==true && node.isParent!=='true');}},
			onSelected: function(id, name, data){
				$("#groupname").val(!data ? "" : name);
			}
		});
	}
	myuploader = $("#imgurl").myImgUploader({
		uploadDir: "manufacturer_img"
	});
	
	$("#form").ligerForm({inputWidth: 300});
	
	verifyForm("form", {}, function(){
		$("#form").ajaxForm(function(data){
			UiUtil.isSuccess(data, "修改农资厂商信息成功", function(){
				UiUtil.closeForm(true);
			});
		});
	});
	
	$("#submit1").click(function(){
		UiUtil.lockButton('submit1');
		$("#form").submit();
	});

	$("#cancel1").click(function(){
		UiUtil.closeForm();
	});
	$("#manufacturerCoords").click(function(){
		$.ligerDialog.open({
            top:20,
            width: 750,
            height: 530,
            title: "选择农资厂商坐标 - 拖动标注点确定农资厂商位置",
            url: "${path}/manufacturer/setMapManufacturer.do?manufacturerid=${manufacturer.manufacturerid}",
            data: {
            	lng: $("#lng").val(),
            	lat: $("#lat").val()
            },
            onClose:function(){
            	var dialogData = this.get('data');
            	if(dialogData.newLng){
            		$("#lng").val(dialogData.newLng);
            		$("#lat").val(dialogData.newLat);
            		setCompanyCoords();
            	}
            }
        });
	});
	setCompanyCoords();
});
function setCompanyCoords(){
	var lng = $("#lng").val();
	if(lng){
		$("#manufacturerCoords").val("经度："+lng+"；纬度："+$("#lat").val());
	}else{
		$("#manufacturerCoords").val('');
	}
}
</script>
</body>
</html>